﻿
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;


namespace DH.Data
{
    public class DHDbContext : DbContext
    {
        public DHDbContext(DbContextOptions<DHDbContext> options) : base(options)
        {
            //Database.SetInitializer(new MigrateDatabaseToLatestVersion<SchoolDBContext, SchoolDataLayer.Migrations.Configuration>("SchoolDBConnectionString"));
            //this.Configuration.AutoDetectChangesEnabled = false;
            //this.Configuration.ValidateOnSaveEnabled = false;
            //this.Configuration.LazyLoadingEnabled = false;
            //this.Configuration.ProxyCreationEnabled = false;


        }
        
      
        protected override void OnModelCreating(ModelBuilder builder)
        {
            //如果是Npgsql,引用 Npgsql.EntityFrameworkCore.PostgreSQL
            //启用Guid主键类型扩展            
            //builder.HasPostgresExtension("uuid-ossp");

            builder.Build();//完成实体类和表的映射关系

            base.OnModelCreating(builder);
        }

    }
}
